<!--
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
    file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<!--
    Copyright 2019 Joyent, Inc.
-->

<div class="server-page-header"></div>


<div class="actions">
  {{#role "operators"}}
  <div class="notes-component-container"></div>
  <div class="btn-group">
    <a class="btn dropdown-toggle btn-info" data-toggle="dropdown" href="#">
      Actions <span class="caret"></span>
    </a>

    <ul class="dropdown-menu dropdown-menu-right">
      <li><a class="reboot"><i class="fa fa-refresh"></i> Reboot Server</a></li>
      <li class="divider"></li>
      <li><a class="factory-reset"><i class="fa fa-repeat"></i> Factory Reset (DANGER)</a></li>
      <li><a class="forget"><i class="fa fa-trash-o"></i> Forget Server (DANGER)</a></li>
    </ul>
  </div>
  {{#unless setup}}
      {{#ifCond setup_state '!=' 'running'}}
        <div class="btn-group">
          <button class="btn btn-info setup">Setup Server</button>
        </div>
    {{/ifCond}}
  {{/unless}}
  {{/role}}
</div>

<div class="memory-overview-container"></div>
<div class="disk-overview-container"></div>

<section>
    <div class="row">

    <div class="col-md-6">
        <h3>Overview</h3>

        <div class="overview">
            <div class="item">
              <div class="item-label">Hostname</div>
              <div class="item-content">{{hostname}}</div>
            </div>

          {{#if encrypted}}
              <div class="item">
                <div class="item-label">Zpool Encrypted</div>
                <div class="item-content">
                      <span class="enabled"><i class="fa fa-check"></i>Encrypted</span>
                </div>
              </div>
          {{/if}}

          <div class="item rack">
            <div class="item-label">Rack</div>
            <div class="item-content">
              {{#if rack_identifier}}
              <span class="value">{{rack_identifier}}</span>
              {{#role "operators"}}
              <a class="change-rack-id"><i class="fa fa-pencil"></i></a>
              {{/role}}
              {{else}}
            {{#role "operators"}}
            <a class="change-rack-id"><span class="none">No Rack Assigned <i class="fa fa-pencil"></i></span></a>
            {{/role}}
          {{/if}}
        </div>
      </div>
      {{#unless headnode}}
      <div class="item">
        <div class="item-label">Provisioning</div>
        <div class="item-content">
          {{#if reserved}}
              <span class="disabled"><i class="fa fa-times"></i> Disabled</span>
              {{#role "operators"}}
              <a class="change-reserve">Enable Provisioning <i class="fa fa-check"></i></a>
          {{/role}}
          {{else}}
              <span class="enabled"><i class="fa fa-check"></i> Enabled</span>
              {{#role "operators"}}
              <a class="change-reserve">Disable <i class="fa fa-times"></i></a>
          {{/role}}
          {{/if}}
        </div>
      </div>
      <div class="item">
        <div class="item-label">Reservation Ratio <a class="help-text"
          title="Ratio of server memory reserved to not be used by Virtual Machines"
          data-toggle="tooltip"
          data-trigger="hover"><i class="fa fa-question-sign"></i></a>
        </div>
        <div class="item-content">
          <span class="reservation-ratio">{{reservation_ratio}}</span>
          <a class="change-reservation-ratio">Change Ratio <i class="fa fa-pencil"></i></a>
        </div>
      </div>
      {{/unless}}
    </div>
  </div>{{! /span}}

  <div class="col-md-6">
    <h3>Platform</h3>
    <div class="platform">
      <div class="item current">
        <div class="item-label">Current</div>
        <div class="item-content">{{current_platform}}</div>
      </div>
      <div class="item boot">
        <div class="item-label">Next Boot</div>
        <div class="item-content">
          <span class="value">{{boot_platform}}</span>
          {{#role "operators"}}
            {{#unless headnode}}
              <a class="change-platform"><i class="fa fa-pencil"></i></a>
            {{/unless}}
          {{/role}}
        </div>
      </div>
    </div> {{! platform }}
  </div>
</div>{{! /row}}
</section>

<section>
<div class="row">
  <div class="col-md-12">
    <h3>Network Interfaces
      {{#role "operators"}}
      <div class="actions pull-right">
        <button class="btn btn-sm btn-info manage-nics"><i class="fa fa-pencil"></i> NIC Tags</i></button>
        {{#unless headnode}}
        <button class="btn btn-sm btn-info manage-link-aggr"><i class="fa fa-pencil"></i> Link Aggregation</i></button>
        {{/unless}}
      </div>
      {{/role}}
    </h3>
    <div class="server-nics"></div>
  </div>
</div>
</section>

<section>
<div class="row">
  <div class="col-md-8">
    <h3>Hardware</h3>
    <table class="table hardware">
      <tbody>
        <tr>
          <th>CPU Type</th>
          <td>{{cpu_type}}</td>
        </tr>
        <tr>
          <th>CPU Sockets / Cores</th>
          <td>{{cpu_sockets}} / {{cpu_cores}}</td>
        </tr>
        <tr>
          <th>Online CPUs</th>
          <td>{{cpu_online_cpus}}</td>
        </tr>
        <tr>
          <th>Simultaneous multi-threading enabled</th>
          <td>{{smt_enabled}}</td>
        </tr>
        <tr>
          <th>Serial Number</th>
          <td>{{serial_number}}</td>
        </tr>
        <tr>
          <th>Total Memory</th>
          <td>{{total_memory}} MiB</td>
        </tr>
        <tr>
          <th>Total Disk Space</th>
          <td>{{total_quota}} GB</td>
        </tr>
        <tr>
          <th>Disk Layout</th>
          <td>{{disk_layout}}</td>
        </tr>
      </tbody>
    </table>
  </div>

  <div class="col-md-4">
    <h3>Serial Console</h3>
    <div class="serial-console">
      <div class="key-value-list">
        <div class="item row">
          <div class="item-label col-md-7">Default Console</div>
          <div class="item-content col-md-5">
            <span class="default-console">{{default_console}}</span>
          </div>
        </div>
        <div class="item row">
          <div class="item-label col-md-7">Serial</div>
          <div class="item-content col-md-5">
            <span class="serial">{{serial}}</span>
          </div>
        </div>
        <div class="item row">
          <div class="item-label col-md-7">Serial Speed</div>
          <div class="item-content col-md-5">
            <span class="serial-speed">{{serial_speed}}</span>
          </div>
        </div>
        {{#role "operators"}}
        <div class="item change">
          <a class="change-serial-console">Change Console Settings <i class="fa fa-pencil"></i></a>
        </div>
        {{/role}}
      </div>
    </div>
  </div>
</div>
</section>

<section class="row">
  <div class="col-md-6">
    <h3>Disks</h3>
    <div class="disks">
      {{#each disks}}
      <div class="disk">
        <div class="name">{{this.name}}</div>
        <div class="size">{{this.size}} GB</div>
      </div>
      {{/each}}
    </div>
  </div>
  <div class="col-md-6">
    <h3>Traits
      {{#role "operators"}}
      <div class="actions">
        <button class="btn btn-info btn-sm modify-traits"><i class="fa fa-pencil"></i> Modify Traits</button>
      </div>
      {{/role}}
    </h3>

    {{#if traits.length}}
    <table class="traits table">
      <tbody>
        {{#each traits}}
        <tr>
          <td style="width: 150px;">{{this.name}}</td>
          <td class="trait-value">{{this.value}}</td>
        </tr>
        {{/each}}
      </tbody>
    </table>
    {{else}}
    <div class="zero-state">There are no traits configured for this server.</div>
    {{/if}}
  </div>
</section>

<section class="row">
    <div class="col-md-12">
        <h3>Virtual Machines</h3>
        <div class="vms-region"></div>
    </div>
</section>
